package cn.lx.expansion.dynamic;

import cn.lx.expansion.GamePlayer;
import cn.lx.expansion.GamePlayerProxy;
import cn.lx.expansion.IGamePlayer;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author lixin
 * @Classname Client
 * @Description TODO
 * @Date 2019/10/5 上午10:58
 */
public class Client {
    public static void main(String[] args) {
        IGamePlayer iGamePlayer = new GamePlayer("lixin");

        // 定义一个handler
        InvocationHandler handler = new GamePlayTH(iGamePlayer);

        ClassLoader classLoader = iGamePlayer.getClass().getClassLoader();

        IGamePlayer proxy = (IGamePlayer) Proxy.newProxyInstance(classLoader, new Class[]{IGamePlayer.class}, handler);


        proxy.login("lx", "pwd");

        proxy.killBoss();

        proxy.upgrade();
    }
}
